<template>
	<view class="container">
		<view class="mask-content">
			<!-- 优惠券页面，仿mt -->
			<view v-if="couponList.length > 0" class="coupon-item" v-for="(item,index) in couponList" :key="index">
				<view class="con">
					<view class="left">
						<text class="title">{{item.level}}元区折扣商品{{item.discount}}折优惠券</text>
						<text class="time">{{item.createdTime}}</text>
					</view>
					<view class="right">
						<text></text>
						<text class="text-red">{{item.level}}元专区使用</text>
					</view>

					<view class="circle l"></view>
					<view class="circle r"></view>
				</view>
				<text class="tips">限折扣区商品使用</text>
			</view>
			<view class="response text-center text-sm text-gray padding-tb">{{couponList.length == 0 ? '暂无可用优惠券' : '没有更多了'}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				couponList: []
			}
		},
		onLoad() {
			var that = this;
			that.$network.request("UserAction/myCoupon", {}, function(res) {
				that.couponList = res.data.list;
			}, "", function(res) {
				console.error(JSON.stringify(res))
				uni.showToast({
					icon: 'none',
					title: '加载失败',
					duration: 1200
				})
			});
		},
		methods: {
			
		}
	}
</script>

<style lang="scss">
	/* 优惠券面板 */
	.mask {
		display: flex;
		align-items: flex-end;
		position: fixed;
		left: 0;
		top: var(--window-top);
		bottom: 0;
		width: 100%;
		background: rgba(0, 0, 0, 0);
		z-index: 9995;
		transition: .3s;

		.mask-content {
			width: 100%;
			min-height: 30vh;
			max-height: 70vh;
			background: #f3f3f3;
			transform: translateY(100%);
			transition: .3s;
			overflow-y: scroll;
		}

		&.none {
			display: none;
		}

		&.show {
			background: rgba(0, 0, 0, .4);

			.mask-content {
				transform: translateY(0);
			}
		}
	}

	/* 优惠券列表 */
	.coupon-item {
		display: flex;
		flex-direction: column;
		margin: 20upx 24upx;
		background: #fff;

		.con {
			display: flex;
			align-items: center;
			position: relative;
			height: 120upx;
			padding: 0 30upx;

			&:after {
				position: absolute;
				left: 0;
				bottom: 0;
				content: '';
				width: 100%;
				height: 0;
				border-bottom: 1px dashed #f3f3f3;
				transform: scaleY(50%);
			}
		}

		.left {
			display: flex;
			flex-direction: column;
			justify-content: center;
			flex: 1;
			overflow: hidden;
			height: 100upx;
		}

		.title {
			font-size: 32upx;
			color: $font-color-dark;
			margin-bottom: 10upx;
		}

		.time {
			font-size: 24upx;
			color: $font-color-light;
		}

		.right {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			font-size: 26upx;
			color: $font-color-base;
			height: 100upx;
		}

		.price {
			font-size: 44upx;
			color: $base-color;

			&:before {
				content: '￥';
				font-size: 34upx;
			}
		}

		.tips {
			font-size: 24upx;
			color: $font-color-light;
			line-height: 60upx;
			padding-left: 30upx;
		}

		.circle {
			position: absolute;
			left: -6upx;
			bottom: -10upx;
			z-index: 10;
			width: 20upx;
			height: 20upx;
			background: #f3f3f3;
			border-radius: 100px;

			&.r {
				left: auto;
				right: -6upx;
			}
		}
	}
</style>
